function initConfig(attr, _this) {
  if (attr.cx == -1) {
    attr.cx = _this._width * 0.5;
  }
  if (attr.cy == -1) {
    attr.cy = _this._height * 0.5;
  }
  if (attr["inner-radius"] == -1) {
    attr["inner-radius"] = _this._min * 0.4;
  }
  if (attr["out-radius"] == -1) {
    attr["out-radius"] = _this._min * 0.45;
  }
}
export default [
  "number",
  "json",
  "string",
  function ($number, $json, $string) {
    return {
      attrs: {
        cx: $number(-1), //圆心横坐标
        cy: $number(-1), //圆心纵坐标
        "inner-radius": $number(-1), //圆环内半径
        "out-radius": $number(-1), //圆环外半径
        data: $json([]),
        startDeg: $number(-1.1 * Math.PI), //起始角度
        deg: $number(1.2 * Math.PI), //跨越弧度
        "inner-ring-color": $string("#aba9a9"), //内环颜色
        "out-ring-color": $string("#ffffff"), //外环颜色,
        offset: $number(2), //内外环差值
      },
      link(painter, attr) {
        //初始化配置项
        initConfig(attr, this);
        //配置画笔
        let config = {
          fillStyle: attr["inner-ring-color"],
          "arc-start-cap": "round",
          "arc-end-cap": "round",
        };
        // 内环
        painter
          .config(config)
          .fillArc(
            attr.cx,
            attr.cy,
            attr["inner-radius"] + attr.offset,
            attr["out-radius"] - attr.offset,
            attr.startDeg,
            attr.deg
          );
        //外环
        config.fillStyle = attr["out-ring-color"];
        painter
          .config(config)
          .fillArc(
            attr.cx,
            attr.cy,
            attr["inner-radius"],
            attr["out-radius"],
            attr.startDeg,
            attr.deg *
              (Number(attr.data.availLimit) / Number(attr.data.creditLimit))
          );
      },
    };
  },
];
